package com.clothes.adp;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.clothes.R;
import com.clothes.mdoel.ClothesTable;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2018/4/5 0005.
 */

public class SelectAdapter extends BaseAdapter {

    private Context context;
    private List<ClothesTable> list;

    public SelectAdapter(Context context, List<ClothesTable> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.item_calime, null);
            holder = new ViewHolder(view);
            view.setTag(holder);
        }else {
            holder = (ViewHolder) view.getTag();
        }
        ClothesTable info = list.get(i);
        holder.tvDate.setText(info.getClaimedDate());
        holder.tvKh.setText(info.getModelNumber());
        holder.tvColor.setText(info.getColor());
        holder.tvSize.setText(info.getSize());
        holder.tvNum.setText((info.getClaimed() - info.getSubmit())+"件");
        return view;
    }

    public class ViewHolder {
        @Bind(R.id.tv_time)
        TextView tvDate;
        @Bind(R.id.tv_kh)
        TextView tvKh;
        @Bind(R.id.tv_color)
        TextView tvColor;
        @Bind(R.id.tv_size)
        TextView tvSize;
        @Bind(R.id.tv_num)
        TextView tvNum;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
